<template>
	<view>
		<pickerModule :picker="item" v-for="(item, index) in picker" :key="index" @pickerChange="pickerChange"></pickerModule>
		<baseForm :column.sync="column" @submitFun="submitFun" :submitStatus="submitDisable" :button="button"></baseForm>
		<progressBox :auditVos="auditVos" dictcode="dict_audit_status"></progressBox>
		<view class="buttons" v-if="getApprovalShow('applyStatus')">
			<button size="mini" class="middleButton" @click="pass('用餐', itemData)">通过</button>
			<button size="mini" class="middleButton" @click="unpass('用餐', itemData)">不通过</button>
		</view>
	</view>
</template>

<script>
import baseForm from '@/wxcomponents/form/form.vue';
import pickerModule from '@/wxcomponents/form/picker.vue';
import { format, dectList } from '@/libs/common.js';
import progressBox from '@/wxcomponents/commonLayout/progressLevel.vue';
import userMixins from '@/libs/userMixins.js'
import approvalMixins from '@/libs/approvalMixins.js'
import formMixins from '@/libs/formMixins.js'
export default {
	mixins: [userMixins, approvalMixins, formMixins],
	data() {
		return {
			itemData: '',
			auditVos: '',
			button: {
				hide: true
			},
			column: [
				{
					label: '用餐日期',
					name: 'dinnerTime',
					type: 'normalInput',
					disabled: true,
					required: false,
					value: ''
				},
				{
					label: '被接待单位',
					name: 'entertainCustomers',
					type: 'normalInput',
					disabled: true,
					required: false,
					value: ''
				},
				{
					label: '用餐人数',
					name: 'dinnerNumbers',
					type: 'normalInput',
					inputType: 'number',
					disabled: true,
					required: false,
					value: ''
				},
				{
					label: '附件(最多上传三张)',
					type: 'upload',
					url: '/stu/common/uploadFile',
					docFileId: '',
					docFileUrl: '',
					attachmentVoListStr: '',
					limitSize: 3,
					disabled: true
				}
			],
		};
	},
	async onLoad(option) {
		this.itemData = JSON.parse(option.data);
		this.getDetail();
	},
	methods: {
		async getDetail() {
			let self = this;
			let caseMap = [
				{
					condition() {	// 详情
						return self.itemData.detailType == 'detail'
					},
					async func() {
						let resp = await self.$http.get({
							url: `/oa/wechat/dinnerApply/detail/${self.itemData.id}`
						});
						self.assignFormDataToViewModel(resp.result, self.column);
						// 时间特殊处理
						let columnItem = self.getColumnItemByKeyAndValue(self.column, 'name', 'dinnerTime');
						columnItem.value = resp.result.dinnerTime.substring(0, 10);
						self.auditVos = resp.result.audits;
					}
				},
				{
					condition() {	// 审批
						return self.itemData.detailType == 'approval'
					},
					async func() {
						let resp = await self.$http.get({
							url: `/oa/wechat/dinnerApply/detail/${self.itemData.id}`
						});
						self.assignFormDataToViewModel(resp.result, self.column);
						// 时间特殊处理
						let columnItem = self.getColumnItemByKeyAndValue(self.column, 'name', 'dinnerTime');
						columnItem.value = resp.result.dinnerTime.substring(0, 10);
						self.auditVos = resp.result.audits;
					}
				},
			]
			let findOne = caseMap.filter(item => {
				return item.condition()
			})[0]
			if (!findOne) {
				alert(`getDetail方法出错`)
			}
			findOne.func();
		}
	},
	components: {
		baseForm,
		pickerModule,
		progressBox
	},
	watch: {}
};
</script>

<style></style>
